import os.path
import requests

from ..util.log_util import logger


class Base:
    def __init__(self):
        self.url = "https://qyapi.weixin.qq.com/cgi-bin/user"

    def token(self):
        base_dir = os.path.dirname(__file__)
        file_path = os.path.join(base_dir, "../token/token.txt")
        file_path = os.path.abspath(file_path)
        with open(file_path, "r") as f:
            token = f.read()
            return token

    def send(self, method, url, **kwargs):
        logger.debug(f'请求"{method}",url"{url}",**kwargs"{kwargs}"')
        return requests.request(method, url, **kwargs)
